﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>批处理</title>
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        var nodeID = GetQueryString("NodeID");
        $(function () {

            //获取节点属性
            var node = new Entity("BP.WF.Template.NodeSimple", nodeID);
            html = "";
            html += "<tr>";
            html += "<th>#</th>";
            html += "<th>节点ID</th>";
            html += "<th>名称</th>";
            html += "<th>审核组件状态</th>";
            html += "</tr>";

            //获得节点s.
            var nodes = new Entities("BP.WF.Nodes");
            nodes.Retrieve("FK_Flow", node.FK_Flow);
            var frmNode = null;

            for (var i = 0; i < nodes.length; i++) {

                var json = nodes[i];

                $("<tr><td>" + (i + 1) + "</td><td>" + json.NodeID + "</td><td>" + json.Name + "</td><td><select id='DDL_FWC_" + json.NodeID + "' onchange=SetNodeFWCSta('" + json.NodeID + "')></select></td></tr>").appendTo($("#sln"));
                InitBar(json.NodeID);
            }

            return;

        });
        function InitBar(nodeID) {
            html = "";

            html += "<option id='" + nodeID + "' value='0' >&nbsp;&nbsp;&nbsp;&nbsp;禁用&nbsp;&nbsp;&nbsp;&nbsp;</option>";
            html += "<option id='" + nodeID + "' value='1' >&nbsp;&nbsp;&nbsp;&nbsp;启用&nbsp;&nbsp;&nbsp;&nbsp;</option>";
            html += "<option id='" + nodeID + "' value='2' >&nbsp;&nbsp;&nbsp;&nbsp;只读&nbsp;&nbsp;&nbsp;&nbsp;</option>";

            var selid = "DDL_FWC_" + nodeID;
            //加载保存的下拉选项
            document.getElementById(selid).innerHTML = html;
            var en = new Entity("BP.WF.Node", nodeID);
            $("#" + selid + " option[value='" + en.FWCSta + "']").attr("selected", "selected");
        }

        //下拉列表选择的时候自动保存
        function SetNodeFWCSta(nodeID) {

            var fwcSta = $("#DDL_FWC_" + nodeID + " option:selected").val();

            if (nodeID.indexOf('01') == nodeID.length - 2) {
                //获得nodeID.
                var node = new Entity("BP.WF.Node", nodeID);
                node.FWCSta = 2;
                node.Update();
                alert('开始节点审核组件状态必须为只读,并且不能修改.');
                window.location.reload();
                return;
            }

            //获得nodeID.
            var node = new Entity("BP.WF.Node", nodeID);
            node.FWCSta = fwcSta;
            node.Update();


            var mypk = node.NodeFrmID + "_" + node.NodeID + "_" + node.FK_Flow;
            var frmNode = new Entity("BP.WF.Template.FrmNodeExt");
            frmNode.SetPKVal(mypk);
            if (frmNode.RetrieveFromDBSources() == 1) {

                if (fwcSta == 0)
                    frmNode.IsEnableFWC = 0;
                else
                    frmNode.IsEnableFWC = 1;

                frmNode.Update();
            }
        }
    </script>
</head>
<body style=" margin:5px; padding:5px;">
    <center>
        <h5>批量设置-选择后自动保存</h5>
        <div>
            <table id="sln" style="width:60%;" class="table table-bordered table-hover table-condensed">
                <tr>
                    <th> # </th>
                    <th> ID </th>
                    <th> 名称 </th>
                    <th> 状态 </th>
                </tr>
            </table>
        </div>

        <fieldset>
            <legend id="help"> 样式 </legend>

            <img src="BatchFWC.png" style="width:60%;" />

        </fieldset>
    </center>

</body>
</html>
